package demo05.FactoryPattern.pizzaImp;

import demo05.FactoryPattern.pizzaFormImp.Cheese;
import demo05.FactoryPattern.pizzaFormImp.Clams;
import demo05.FactoryPattern.pizzaFormImp.Dough;
import demo05.FactoryPattern.pizzaFormImp.Pepperoni;
import demo05.FactoryPattern.pizzaFormImp.Sauce;
import demo05.FactoryPattern.pizzaFormImp.Veggies;

/**
 * 抽象的披萨（产品类）
 * */
public abstract class Pizza {
	public   String name;
	//披萨的组成接口
	 public Dough dough;//面团
	 public Sauce sauce;//酱
	 public Veggies veggies[];//蔬菜
	 public Cheese cheese;//奶酪
	 public Pepperoni pepperoni;//意大利辣味香肠
	 public Clams clam;//蛤
	
	//供子类实现的抽象方法（通用方法）
	public abstract void prepare();

	public void bake() {
		System.out.println("烘烤25到35分钟...");
	}

	public void cut() {
		System.out.println("把比萨饼切成对角片,");
	}

	public void box() {
		System.out.println("把披萨打包入盒。");
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public String toString() {
		StringBuffer result = new StringBuffer();
		result.append("---- " + name + " ----\n");
		if (dough != null) {
			result.append(dough);
			result.append("\n");
		}
		if (sauce != null) {
			result.append(sauce);
			result.append("\n");
		}
		if (cheese != null) {
			result.append(cheese);
			result.append("\n");
		}
		if (veggies != null) {
			for (int i = 0; i < veggies.length; i++) {
				result.append(veggies[i]);
				if (i < veggies.length-1) {
					result.append(", ");
				}
			}
			result.append("\n");
		}
		if (clam != null) {
			result.append(clam);
			result.append("\n");
		}
		if (pepperoni != null) {
			result.append(pepperoni);
			result.append("\n");
		}
		return result.toString();
	}

}
